﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

using System.Windows.Data;
using System.Windows.Media;

namespace ESC.Designer.Resources
{
    public class FQCColorConvert : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var colorRed = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("Red");
            var colorWhite = (System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("White");

            var unchanged = new SolidColorBrush(colorWhite);
            var changed = new SolidColorBrush(colorRed);

            decimal? fqcvalue = values[0] as decimal?;
            decimal? valueLower = values[1] as decimal?;
            decimal? valueUpper = values[2] as decimal?;
            if (valueLower != null && fqcvalue != null && valueLower > fqcvalue)
                return changed;
            if (valueUpper != null && fqcvalue != null && valueUpper < fqcvalue)
                return changed;
            return unchanged;
        }
        

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
